﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: ConstraintException.cs
//
//  Description: Excpetion is thrown if a property is null but mandatory.
// 
//--------------------------------------------------------------------------

using System;
using System.Runtime.Serialization;

namespace Chili.Opf3
{
	/// <summary>
	/// Exception is thrown if a property marked as mandatory
	/// (<see cref="Opf3.FieldAttribute.AllowDBNull">AllowDBNull</see> is false) is tried to be
	/// saved with a value that corresponds DBNull (for example null).
	/// </summary>
	/// <remarks>
	/// This exception is thrown if a property marked with the
	/// <see cref="Opf3.FieldAttribute.AllowDBNull">AllowDBNull</see> property set to false is
	/// containing Null and the program tries to save it to the storage.
	/// </remarks>
	[Serializable]
	public sealed class ConstraintException : Exception
	{
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="ConstraintException">ConstraintException Class</see>.
		/// </summary>
		private ConstraintException(SerializationInfo info, StreamingContext context) : base(info, context)
		{
		}

		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Opf3.ConstraintException">ConstraintException Class</see>.
		/// </summary>
		public ConstraintException()
		{ 
		}

		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Opf3.ConstraintException">ConstraintException Class</see>.
		/// </summary>
		/// <param name="message">A message that describes the current exception.</param>
		public ConstraintException(string message) : base(message)
		{ 
		}

		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Opf3.ConstraintException">ConstraintException Class</see>.
		/// </summary>
		/// <param name="message">A message that describes the current exception.</param>
		/// <param name="inner">The exception that caused the current exception.</param>
		public ConstraintException(string message, Exception inner) : base(message, inner)
		{
		}
	}
}
